<template>    <!--该页面为在线仪器页面-->
  <div>
    <el-breadcrumb separator="/"> <!--面包屑 -->
      <el-breadcrumb-item><i class="el-icon-s-home" style="margin-right: 15px;font-size: 16px"></i>在线设备</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="info">
      <div v-for="(item,index) in instrumentInfo" :key="index">
        <el-card shadow="always" style="margin-top: 10px;">
          <div slot="header"><el-row><div class="rectangularBar"></div><div class="heardTitle">{{item[0].station_name}}</div></el-row></div>
          <el-table :data="item" style="width: 100%" stripe>
            <el-table-column type="index" label="序号" width="80" align="center"></el-table-column>
            <el-table-column prop="instr_name" label="设备名称" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="model" label="设备型号" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="spec" label="设备规格" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column prop="instr_number" label="设备编号" align="center" show-overflow-tooltip></el-table-column>
            <el-table-column label="状态" width="120">
              <template slot-scope="scope">
                <div class="statusIcon" :style="{'background-color':(scope.row.onlineStatus === '在线' ?'#009641':'#E83131')}"></div>
                <div>{{scope.row.onlineStatus}}</div>
              </template>
            </el-table-column>
          </el-table>
        </el-card>
      </div>
    </div>
  </div>
</template>

<script>
import Bus from '../../public/eventBus.js'
import moment from 'moment';
const uuid = require('node-uuid');
import myMqtt from '@/public/mqtt.js';
import sessionStorage from '../../public/storage.js';
export default {
  data() {
    return {
      show: false,
      instrumentInfo:[], //仪器列表
    };
  },
  methods: {
    //加载页面时显示仪器信息
    async getInstrumentList(){
      const ret = await this.$http.get("/onlineInstrument/getInstrumentList");
      this.instrumentInfo = ret.result;   //获取在线仪器信息
    }
  },
  mounted() {
    this.getInstrumentList();
    Bus.$on('reciveInstrEvent',(reciveMessage) => {
      this.getInstrumentList();
    });
    this.$once('hook:beforeDestroy', () => {
      Bus.$off(['reciveInstrEvent']);
    });
  }
};
</script>
<style lang="scss" scoped>
@import "./OnlineInstrument.scss";
</style>